<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::get('/', function () {
    // return view('welcome');
    echo phpinfo();
});

Route::group(['namespace' => 'Admin', 'prefix' => 'admin'], function(){
    // 控制器在 "App\Http\Controllers\Admin" 命名空间下
    Route::get('/', 'IndexController@index')->name('admin.index');
    Route::get('index', 'IndexController@index')->name('admin.index');

    //测试接口
    Route::get('test/index', 'TestController@index')->name('test.index');
    Route::get('test/recharge', 'TestController@recharge')->name('test.recharge');
    Route::get('test/validActive', 'TestController@validActive')->name('test.validActive');

    Route::any('chart/chartData', 'IndexController@getChartData')->name('admin.chart.chartData');

    //上传图片
    Route::post('/upload/images', 'UploadController@images')->name('admin.upload.images');

    //用户登录
    Route::get('/login', 'AuthController@toLogin')->name('admin.tologin');
    Route::post('/login','AuthController@login')->name('admin.login');
    Route::get('/logout', 'AuthController@logout')->name('admin.logout');
    Route::get('/setPwd','AuthController@toSetPwd')->name('admin.toSetPwd');
    Route::post('/setPwd', 'AuthController@setPwd')->name('admin.setPwd');
    //用户管理
    Route::get('users', 'AdminController@index')->name('admin.users.index');
    Route::post('users', 'AdminController@store')->name('admin.users.store');
    Route::get('users/create', 'AdminController@create')->name('admin.users.create');
    Route::get('users/{user}', 'AdminController@show')->name('admin.users.show');
    Route::put('users/{user}', 'AdminController@update')->name('admin.users.update');
    Route::delete('users/{user}', 'AdminController@destroy')->name('admin.users.destroy');
    Route::get('users/{user}/edit', 'AdminController@edit')->name('admin.users.edit');
    Route::delete('users/destroyList', 'AdminController@destroyList')->name('admin.users.destroyList');

    // Route::resource('users', 'AdminController');
    //角色管理
    Route::get('roles/{role}/permissions', 'RoleController@permissions')->name('roles.permissions');
    Route::post('roles/{role}/permissions', 'RoleController@updatePermissions')->name('roles.updatePermissions');
    Route::post('roles/destroyList', 'RoleController@destroyList')->name('roles.destroyList');
    Route::resource('roles', 'RoleController');
    //权限管理
    Route::post('menus/destroyList', 'MenuController@destroyList')->name('menus.destroyList');
    Route::resource('menus', 'MenuController');

    //数据库管理
    Route::get('database/backup', 'DatabaseController@backup')->name('database.backup');
    Route::get('database/restore', 'DatabaseController@restore')->name('database.restore');

    //房间配置
    Route::post('gamerooms/destroyList', 'GameRoomController@destroyList')->name('gamerooms.destroyList');
    Route::put('gamerooms/{gameroom}/edit', 'GameRoomController@editStatus');
    Route::resource('gamerooms', 'GameRoomController');

    //商品管理
    Route::post('goods/destroyList', 'GoodsController@destroyList')->name('goods.destroyList');
    Route::put('goods/{goods}/edit', 'GoodsController@editStatus');
    Route::resource('goods', 'GoodsController');

    //兑换商品管理
    Route::post('gifts/destroyList', 'GiftController@destroyList')->name('gifts.destroyList');
    Route::put('gifts/{gift}/edit', 'GiftController@editStatus');
    Route::resource('gifts', 'GiftController');

    //玩家管理
    Route::get('gamers/index', 'GamerController@index')->name('gamers.index');
    Route::get('gamers/online', 'GamerController@onlineGamers')->name('gamers.online');
    Route::get('gamers/forbidden', 'GamerController@forbiddenGamers')->name('gamers.forbidden');
    Route::get('gamers/blackLists', 'GamerController@blackListGamers')->name('gamers.blacklists');//必须放到gamers.show前

    Route::get('gamers/{gamer}', 'GamerController@show')->name('gamers.show');
    Route::delete('gamers/{gamer}', 'GamerController@destroy')->name('gamers.destroy');
    Route::post('gamers/destroyList', 'GamerController@destroyList')->name('gamers.destroyList');
    Route::post('gamers/{gamer}/pushBlackList', 'GamerController@pushBlackList')->name('gamers.pushBlackList');
    Route::put('gamers/{gamer}/popBlackList', 'GamerController@popBlackList')->name('gamers.popBlackList');

    //消息管理
    Route::post('broadcasts/destroyList', 'BroadCastController@destroyList')->name('broadcasts.destroyList');
    Route::resource('broadcasts', 'BroadCastController');
    //广告管理
    Route::post('ads/destroyList', 'AdController@destroyList')->name('ads.destroyList');
    Route::resource('ads', 'AdController');

    //邮件管理
    Route::post('emails/destroyList', 'EmailController@destroyList')->name('emails.destroyList');
    Route::resource('emails', 'EmailController');

    //每日任务
    Route::post('daliyMissions/destroyList', 'EmailController@destroyList')->name('daliyMissions.destroyList');
    Route::resource('daliyMissions', 'DaliyMissionController');
    //成就
    Route::post('achievements/destroyList', 'AchievementController@destroyList')->name('achievements.destroyList');
    Route::resource('achievements', 'AchievementController');

    //渠道商
    Route::post('channels/destroyList', 'ChannelController@destroyList')->name('channels.destroyList');
    Route::patch('channels/{channel}/edit', 'ChannelController@editStatus');
    Route::resource('channels', 'ChannelController');

    //数据统计
    Route::get('statistics/index', 'StatisticsController@index')->name('statistics.index');

    //订单
    Route::get('orders/index', 'OrderController@index')->name('orders.index');
});


//支付等
Route::group(['namespace' => 'Service', 'prefix' => 'service'], function() {
    //爱贝支付
    Route::get('iapppay/index', 'IapppayController@index')->name('iapppay.index');
    Route::post('iapppay/order', 'IapppayController@order')->name('iapppay.order');
    Route::post('iapppay/pay', 'IapppayController@pay')->name('iapppay.pay');
    Route::post('iapppay/notify', 'IapppayController@notify')->middleware('admin.cross')->name('iapppay.notify');
});